﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Data;

using System.Windows.Forms;
using ModularAndPlugin.Core.Composition;
using ModularAndPlugin.WinApp.Contracts;
using SailHero.Soft.FrameWork.Models;
using WeifenLuo.WinFormsUI.Docking;

namespace UI.WinForm.Clients
{
    public static class ClientsCommandFacade
    {
        public static IModuleHandler ModuleHandler { get; set; }

        public static void MenuAddClient(object sender, EventArgs e)
        {
            NewClient();
        }

        public static void MenuClientList(object sender, EventArgs e)
        {
            ViewClient();
        }
        public static void ClientsProducts(object sender, EventArgs e)
        {
            var delgt = ModuleHandler.FindCmdByKey("ViewData");
            if (delgt == null) return;
            ((Func<bool>)delgt).Invoke();
        }

        [CommandAttibute("NewClient")]
        public static bool NewClient()
        {
            frmClient f = new frmClient();
            IHost hst = ModuleHandler.Host;
            hst.showForm(f);
            return true;
        }

        [CommandAttibute("ViewClient")]
        public static bool ViewClient()
        {
            frmClients f = new frmClients();
            ModuleHandler.Host.showForm(f);
            return true;
        }

        [CommandAttibute("SelectClients")]
        public static DataSet SelectClients()
        {
            frmClients f = new frmClients();
            f.ShowDialog();
            DataSet l = f.SelectedClients;
            return l;
        }

        [CommandAttibute("GetClientName")]
        public static string GetClientName(int id_)
        {
            ClientsService _cs = new ClientsService();
            return _cs.GetClientName(id_);
        }

        [CommandAttibute("GetClientList")]
        public static List<TB_CLIENTS> GetClientList()
        {
            ClientsService _cs = new ClientsService();
            return _cs.GetClientsDataTable();
        }
    }
}
